- 
                Notifications
    You must be signed in to change notification settings 
- Fork 131
CurveAnalysis base class #765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CurveAnalysis base class #765
Conversation
fb14230    to
    5d3a33f      
    Compare
  
    5d3a33f    to
    3a4f605      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be in good shape. Do you also need to refactor the other analysis classes to this?
| A method to format curve data. By default this method takes y value average | ||
| over the same x values and then sort the entire data by x values. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| A method to format curve data. By default this method takes y value average | |
| over the same x values and then sort the entire data by x values. | |
| A method to format curve data. By default this method takes the average of the y values | |
| over the same x values and then sort the entire data by x values. | 
This is not something that is needed all the time right? This is most useful for RB correct? Perhaps that's worth mentioning here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this is always done. Because some guess function relies on the sequence ordering, e.g. computing slope by something like dx = x[1] - x[0]. There is no guarantee x values are in ascending order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two things here.
a) averaging the y data
b) sorting according to x data.
Makes sense to always do b). Do we always do a)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, should do. If you concatenate two experiments, you will create experiment data that may consist of something like x = [0,1,2,3,0,1,2,3] that will crash some guess function.
| https://github.com/Qiskit/qiskit-experiments/issues | ||
| """ | ||
| class CurveAnalysis(BaseCurveAnalysis): | ||
| """Base class for curve analyis.""" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a base class is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still base class (e.g. ErrorAmplificationAnalysis(CurveAnalysis)). The reason we introduce BaseCurveAnalysis is to remove boilerplate code in GroupedCurveAnalysis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm the naming gets a bit confusing no? Since CurveAnalysis is still a base class it could be called BaseCurveAnalysis which is already taken. What are the distinctive features between CurveAnalysis (a base class) and BaseCurveAnalysis? Perhaps that can help with the naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a bit more to the class docstring to explain why we have this class? Currently it reads Base class for curve analyis. which is too brief given that we have another class called BaseCurveAnalysis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be clearer once we introduce the GroupCurveAnalysis (perhaps MultiGroupCurveAnalysis to be precise). The base one is the superclass of both CurveAnalysis and GroupCurveAnalysis . The difference between CurveAnalysis and BaseCurveAnalysis is implementation of _run_analysis method. In the group one the logic inside the _run_analysis will be different from CurveAnalysis though each subroutines can be reused. This is why BaseCurveAnalysis only implements subroutines.
        
          
                qiskit_experiments/library/characterization/analysis/drag_analysis.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
      …ure/curve_analysis_baseclass
Co-authored-by: Daniel J. Egger <[email protected]>
d3cde71    to
    62d1609      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks mostly good. The only thing I still find a bit awkward is the naming between CurveAnalysis and BaseCurveAnalysis as both are base classes (see some of the comments below).
| https://github.com/Qiskit/qiskit-experiments/issues | ||
| """ | ||
| class CurveAnalysis(BaseCurveAnalysis): | ||
| """Base class for curve analyis.""" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a bit more to the class docstring to explain why we have this class? Currently it reads Base class for curve analyis. which is too brief given that we have another class called BaseCurveAnalysis.
        
          
                releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
              
                Outdated
          
            Show resolved
            Hide resolved
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial review
        
          
                releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | Curve Analysis Overview | ||
| ======================= | ||
| The base class :class:`CurveAnalysis` implements the multi-objective optimization on | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is starting to get too detailed for class level API docs and should instead be moved to its own separate User Guide on curve analysis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Do we create user guide with this PR? I've already moved some long API docs (basically how code author can override method) to here and left :ref: link in the original place so I cannot simply remove this. Note that this is not a class level docs, this is module docs so I think this is probably okey for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this can be a separate PR, I think we should do a bit of planning on what would make some good mode detailed user guides
Co-authored-by: Daniel J. Egger <[email protected]>
e7f83e9    to
    3a86a25      
    Compare
  
    Co-authored-by: Christopher J. Wood <[email protected]>
3d043d9    to
    3d7a5e4      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, couple more documentation comments
| """Description of curve.""" | ||
| """A dataclass to describe the definition of the curve. | ||
| Args: | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was curious what the "correct" way to comment a dataclass is and found this https://stackoverflow.com/a/51131941
They suggest preferring option (3) using Attributes: rather than using Args:. I didn't test myself, but I wonder if this will will override the empty attribute desciptions currently populated here. Checking the artifact on this PR the attribute doc stirngs are unchanged, but the Parameters: field is populated correctly from these args.
Can you try changing to attributes and checking what the built docs looks like and pick the one you think looks best?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
        
          
                releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
              
                Outdated
          
            Show resolved
            Hide resolved
        
      38ceaa0    to
    d7e25a4      
    Compare
  
            
          
                releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
              
                Outdated
          
            Show resolved
            Hide resolved
        
      There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. @chriseclectic as you have also commented on this PR I'll let you give the final approval.
        
          
                releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                releasenotes/notes/cleanup-curve-analysis-96d7ff706cae5b4e.yaml
              
                Outdated
          
            Show resolved
            Hide resolved
        
      Co-authored-by: Daniel J. Egger <[email protected]>
Co-authored-by: Daniel J. Egger <[email protected]>
…wa1989/qiskit-experiments into feature/curve_analysis_baseclass
317c687    to
    67c942b      
    Compare
  
    …wa1989/qiskit-experiments into feature/curve_analysis_baseclass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Refactor of CurveAnalysis and introduction of BaseCurveAnalysis class Co-authored-by: Daniel J. Egger <[email protected]> Co-authored-by: Christopher J. Wood <[email protected]>


Summary
This PR introduces base class for curve analysis. See #737 for details.
Blocked by #762Details and comments
TODO
groupto curve analysis #715 )